package com.huluobo.a2201mvvm_imdemo.conversation;


import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.huluobo.a2201mvvm_imdemo.chat.ChatActivity;
import com.hyphenate.chat.EMConversation;
import com.hyphenate.easeui.modules.conversation.EaseConversationListFragment;


public class ConversationFragment extends EaseConversationListFragment {
    @Override
    public void onItemClick(View view, int position) {
        super.onItemClick(view, position);
        String conversationId = ((EMConversation) conversationListLayout.getItem(position).getInfo()).conversationId();
        int chatType = 0;
        switch (((EMConversation) conversationListLayout.getItem(position).getInfo()).getType()) {
            case Chat:
                chatType = 1;
                break;
            case GroupChat:
                chatType = 2;
                break;
            case ChatRoom:
                chatType = 3;
                break;
        }

        Intent intent = new Intent(requireContext(), ChatActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("conversationId", conversationId);
        bundle.putInt("chatType", chatType);
        intent.putExtras(bundle);
        startActivity(intent);

    }
}